package com.data.app.service.impl;

import com.data.app.commons.division.DivisionUtils;
import com.data.app.dao.primary.DivisionBaseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DivisionServiceImpl implements DivisionUtils {
    @Autowired
    DivisionBaseDao dao;
    @Override
    public String getDicisionNameByCode(String code) {
        return dao.findDivisionNameBycode(code);
    }
    @Override
    public Map<String,Object> findDivisionNameAndDivisionCode() {
        List<Object[]> divisionInfos = dao.findDivisionNameAndDivisionCode();
        Map<String,Object> map = new HashMap();
        for (Object[] divisionInfo : divisionInfos) {
            map.put(divisionInfo[0].toString(),divisionInfo[1]);
        }
        return map;
    }
}
